﻿using System.Collections;

namespace CsharpPro._1023;

public class Demo
{
    public void TestPrint()
    {
        int[] arr1 = new int[5];
        arr1[0] = 1;
        arr1[4] = 5;
        for (int i = 0; i < arr1.Length; i++)
        {
            Console.WriteLine(arr1[i] + "\t");
        }

        string[] arr2 = new string[5];
        arr2[0] = "Hello";
        arr2[4] = "World";
        for (int i = 0; i < arr2.Length; i++)
        {
            Console.WriteLine(arr2[i] + "\t");
        }

        int[] arr3 = { 1, 2, 3, 4, 5, 6 };
        Console.WriteLine(arr3[0] + "\t");
        Console.WriteLine(arr3[4] + "\t");

        int[,] arr4 = new int[3, 3];
        arr4[0, 0] = 1;
        arr4[1, 1] = 2;
        arr4[2, 2] = 3;

        int[,] arr5 =
        {
            { 1, 2, 3 },
            { 4, 5, 6 },
            { 6, 7, 8 }
        };

        int[] arr6 = { 4, 555, 22, 12, 88 };
        Array.Sort(arr6);
        Array.Reverse(arr6);
        Console.WriteLine();
        foreach (int i in arr6)
        {
            Console.WriteLine(i + "\t");
        }

        ArrayList list = new ArrayList();
        list.Add(1);
        list.Add(2);
        list.Add(3);
        list.Add("abc");
        Console.WriteLine(list.Count);
        Console.WriteLine();
        foreach (Object i in list)
        {

            Console.WriteLine(i + "\t");
        }

        list.Contains("abc");
        Hashtable ht = new Hashtable();
        ht.Add("abc", 1);
        ht.Add("def", 2);
        ht.Add("ghi", 3);
        foreach (DictionaryEntry entry in ht)
        {
            Console.WriteLine(entry.Key + "\t"+entry.Value);
            Console.WriteLine();
        }
        ht.Remove("abc");
    }
}